home *** CD-ROM | disk | FTP | other *** search
- Public Class OpacityForm
- Inherits System.Windows.Forms.Form
-
- #Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
- Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
- Friend WithEvents TrackBar1 As System.Windows.Forms.TrackBar
- Friend WithEvents Button1 As System.Windows.Forms.Button
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.Container
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.TrackBar1 = New System.Windows.Forms.TrackBar()
- Me.CheckBox1 = New System.Windows.Forms.CheckBox()
- Me.TextBox1 = New System.Windows.Forms.TextBox()
- Me.Button1 = New System.Windows.Forms.Button()
- CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'TrackBar1
- '
- Me.TrackBar1.LargeChange = 10
- Me.TrackBar1.Location = New System.Drawing.Point(40, 160)
- Me.TrackBar1.Maximum = 100
- Me.TrackBar1.Name = "TrackBar1"
- Me.TrackBar1.Size = New System.Drawing.Size(312, 42)
- Me.TrackBar1.TabIndex = 2
- Me.TrackBar1.TickFrequency = 10
- Me.TrackBar1.Value = 100
- '
- 'CheckBox1
- '
- Me.CheckBox1.Location = New System.Drawing.Point(256, 32)
- Me.CheckBox1.Name = "CheckBox1"
- Me.CheckBox1.Size = New System.Drawing.Size(144, 16)
- Me.CheckBox1.TabIndex = 1
- Me.CheckBox1.Text = "Make transparent"
- '
- 'TextBox1
- '
- Me.TextBox1.Location = New System.Drawing.Point(40, 32)
- Me.TextBox1.Multiline = True
- Me.TextBox1.Name = "TextBox1"
- Me.TextBox1.Size = New System.Drawing.Size(200, 112)
- Me.TextBox1.TabIndex = 0
- Me.TextBox1.Text = "Click on the checkbox to make this textbox transparent."
- '
- 'Button1
- '
- Me.Button1.Location = New System.Drawing.Point(256, 80)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(120, 48)
- Me.Button1.TabIndex = 3
- Me.Button1.Text = "Fade out and close"
- '
- 'OpacityForm
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(7, 17)
- Me.ClientSize = New System.Drawing.Size(408, 221)
- Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TrackBar1, Me.CheckBox1, Me.TextBox1})
- Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 11!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
- Me.Name = "OpacityForm"
- Me.Text = "OpacityForm"
- CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
-
- End Sub
-
- #End Region
-
- ' change the Opacity property when the user moves the trackbar
-
- Private Sub TrackBar1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged
- Me.Opacity = TrackBar1.Value / 100
- End Sub
-
- ' enforce the transparencykey property
-
- Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
- If CheckBox1.Checked Then
- Me.TransparencyKey = TextBox1.BackColor
- Else
- Me.TransparencyKey = Nothing
- End If
- End Sub
-
- ' fade out the form
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim op As Single
-
- For op = Me.Opacity To 0 Step -0.005
- Me.Opacity = op
- Next
-
- MessageBox.Show("Good-bye, folks!")
- Me.Close()
- End Sub
- End Class
-